<?php
/* @var $this StkContactoController */
/* @var $model StkContacto */
/* @var $form CActiveForm */
?>
<script type="text/JavaScript">
	//$('body').css('background', '#fff');
</script>
<div class="form">
<div id="content2">
<?php
	$baseUrl = Yii::app()->baseUrl; 
	$cs = Yii::app()->getClientScript();	
	$cs->registerScriptFile($baseUrl.'/ckeditor_basic/ckeditor.js');
	$form=$this->beginWidget('CActiveForm', array(
	'id'=>'Stk-contacto-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
      'enableAjaxValidation'=>false,
      'enableClientValidation'=>true,
        'clientOptions'=>array(
            'validateOnSubmit'=>true,
        )
)); 
?>
<?php  $user=StkUsuario::model()->find('LOWER(NombreUsuario)=?',array( Yii::app()->user->name));  ?>
	<table>
		<tr>
			<td WIDTH="50%" >

	<?php echo $form->errorSummary($model); ?>
	<?php if(isset($user) && $model->Apellidos!=""){ ?><!--editar-->
	<div class="row">
		<?php echo $form->textField($model,'Apellidos',array('size'=>50,'maxlength'=>50, 'class'=>'formulary_contact')); ?>
		<?php echo $form->error($model,'Apellidos'); ?>
		
	</div>
	<?php } 
	if(isset($user) && $model->Apellidos=="")//Crear
	{?>
		<div class="row">
	<?php
		echo $form->hiddenField($model,'Apellidos',array('size'=>50,'maxlength'=>50, 'class'=>'formulary_contact', 'value'=> $user->Apellidos)); 
		echo $form->error($model,'Apellidos');
	}?>
		</div>
	<?php
	if(!isset($user) && $model->Apellidos==""){?><!--Usuario No Registrado-->
		<div class="row">
			<?php echo $form->textField($model,'Apellidos',array('size'=>50,'maxlength'=>50, 'class'=>'formulary_contact',  'value'=>'Apellidos','onblur'=>"if (this.value=='') this.value = 'Apellidos'", 'onfocus'=>"if (this.value=='Apellidos') this.value = ''",)); ?>
		<?php echo $form->error($model,'Apellidos'); ?>
		</div>
	<?php }?>
	<div class="row">
	<?php if(isset($user) && $model->Nombres!=""){ ?>
		<?php echo $form->textField($model,'Nombres',array('size'=>50,'maxlength'=>50, 'class'=>'formulary_contact')); ?>
		<?php echo $form->error($model,'Nombres'); ?>
	<?php } 
	if(!isset($user)){?>
		<?php echo $form->textField($model,'Nombres',array('size'=>50,'maxlength'=>50, 'class'=>'formulary_contact', 'value'=>'Nombres','onblur'=>"if (this.value=='') this.value = 'Nombres'", 'onfocus'=>"if (this.value=='Nombres') this.value = ''",)); ?>
		<?php echo $form->error($model,'Nombres'); ?>
	<?php }
	if(isset($user) && $model->Nombres=="")
	{
	?>
		<?php echo $form->hiddenField($model,'Nombres',array('size'=>50,'maxlength'=>50, 'class'=>'formulary_contact', 'value'=>$user->Nombres)); ?>
		<?php echo $form->error($model,'Nombres'); ?>
	<?php
	}
	?>
	
	</div>
	<div class="row">
		<?php if(isset($user) && $model->Email!=""){ ?>
		<?php echo $form->textField($model,'Email',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact')); ?>
		<?php echo $form->error($model,'Email'); ?>
		<?php } 
		if(!isset($user)){?>
			<?php echo $form->textField($model,'Email',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact', 'value'=>'Correo Electrónico','onblur'=>"if (this.value=='') this.value = 'Correo Electrónico'", 'onfocus'=>"if (this.value=='Correo Electrónico') this.value = ''",)); ?>
			<?php echo $form->error($model,'Email'); ?>
		<?php }
		if(isset($user) && $model->Email=="")
		{
		?>
			<?php echo $form->hiddenField($model,'Email',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact', 'value'=>$user->Email)); ?>
			<?php echo $form->error($model,'Email'); ?>
		<?php
		}
		?>
	
		
	</div>

	<div class="row">
		<?php if(isset($user) && $model->Telefono==""){ ?>
		
		<?php echo $form->hiddenField($model,'Telefono',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact', 'value'=>$user->Telefono));  ?>
		<?php echo $form->error($model,'Telefono'); ?>
		<?php } 
		if(!isset($user)){?>
			<?php echo $form->labelEx($model,'Tel&eacutefono (+58-212-0000000)'); ?>
			<?php 
                        $this->widget('CMaskedTextField', array(
				'model' => $model,
				'attribute' => 'Telefono',
				
				'mask' => '+58-___-_______',
				'charMap' => array('_'=>'[0-9]' , ','=>'[,]'),
				'htmlOptions' => array('size' => 50, 'class'=>'formulary_contact'))
			); ?>
			<?php echo $form->error($model,'Telefono'); ?>
		<?php }
		if(isset($user) && $model->Telefono!=""){
		?>
			<?php echo $form->textField($model,'Telefono',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact'));  ?>
		<?php echo $form->error($model,'Telefono'); ?>
		<?php
		}?>
	</div>

	<div class="row">
				<?php if(!isset($user)){ ?>
				<?php echo $form->labelEx($model,'Celular (+58-414-0000000)'); ?>
		<?php 
                    $this->widget('CMaskedTextField', array(
				'model' => $model,
				'attribute' => 'Celular',
				
				'mask' => '+58-___-_______',
				'charMap' => array('_'=>'[0-9]' , ','=>'[,]'),
				'htmlOptions' => array('size' => 50,'class'=>'formulary_contact', 'value'=>'Asunto','onblur'=>"if (this.value=='') this.value = 'Asunto'", 'onfocus'=>"if (this.value=='Asunto') this.value = ''"))
			);
                ?>
		<?php echo $form->error($model,'Celular'); ?>
		<?php }
		if(isset($user) && $model->Celular!="")
		{
		?>
			<?php echo $form->textField($model,'Celular',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact'));  ?>
		<?php echo $form->error($model,'Celular'); ?>
		<?php
		}
		?>
	</div>

	<div class="row">
	<?php if($model->Asunto==""){ ?>
		<?php echo $form->textField($model,'Asunto',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact', 'value'=>'Asunto','onblur'=>"if (this.value=='') this.value = 'Asunto'", 'onfocus'=>"if (this.value=='Asunto') this.value = ''",)); ?>
		<?php echo $form->error($model,'Asunto'); ?>
		<?php } 
		if($model->Asunto!="")
		{
		?>
			<?php echo $form->textField($model,'Asunto',array('size'=>50,'maxlength'=>100, 'class'=>'formulary_contact')); ?>
		<?php echo $form->error($model,'Asunto'); ?>
		<?php
		}
		?>
		
	</div>

	<div class="row">
		<?php if($model->Texto==""){ ?>
		<?php echo $form->textArea($model,'Texto', array('id'=>'Texto', 'value'=>'Escribe aquí...'));?>	
		<?php echo $form->error($model,'Texto'); ?>
		<?php } ?>
		<?php if($model->Texto!=""){
		?>
			<?php echo $form->textArea($model,'Texto', array('id'=>'Texto'));?>	
		<?php echo $form->error($model,'Texto'); ?>
		<?php
		}
		?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Enviar' : 'Guardar', array('class'=>'comment')); ?>
	</div>
	
	<script type="text/javascript">
    CKEDITOR.replace('Texto',
    {
        width : '80%', /* this does the magic */

    //    uiColor : '#9AB8F3'
    });
	</script>
			</td>
			<td >
			<div style="position:relative; margin-top:-250px;">
				<p><strong><?php echo $Data; ?></strong><p>
			</div>
			</td>
		</tr>
	</table>
<?php $this->endWidget(); ?>
</div>
</div><!-- form -->